package main

import (
	"encoding/json"
	"fmt"
)

//实现继承，核心思想是利用匿名结构体

type Human struct {
	Name string `json:"name"`
}

func (h *Human) Say() {
	fmt.Println("hello, ", h.Name)
}

type Man struct {
	Age int `json:"age"`
	Human
}

func main() {

	p1 := &Man{
		Age: 18,
		Human: Human{
			Name: "zhanglin",
		},
	}
	p1.Say()
	data, _ := json.Marshal(p1)
	fmt.Println(string(data))

}
